package com.ccl.iot.privates;import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.Path.Direction;
import android.graphics.RectF;

public class WarningMaskOld extends BitmapMask {
	private int iBackColor = Color.TRANSPARENT;

	public WarningMaskOld(RectF aRect, int aBackColor) {
		super(aRect);
		
		iBackColor = aBackColor;
	}

	@Override
	public boolean paintMask(Canvas aCanvas, RectF aRect) {
		if (aCanvas != null && aRect != null){
			int tWidth = (int) aRect.width();
			int tHeight = (int) aRect.height();
			
			if (tWidth > 0 && tHeight > 0){
				float tRefLen;
				float tXOffset = 0, tYOffset = 0;
				float tCenterX, tCenterY;
				Paint tPaint = new Paint();
				Path tPath = new Path();
				
				tPaint.setAntiAlias(true);
				tPaint.setFilterBitmap(true);

				if (tWidth > tHeight){
					tRefLen = tHeight;
					tCenterY = tRefLen * 0.5f;
					tXOffset = (tWidth - tHeight) * 0.5f;
					tCenterX = tCenterY + tXOffset;
				}else{
					tRefLen = tWidth;
					tCenterX = tRefLen * 0.5f;
					tYOffset = ((tHeight - tWidth) * 0.5f);
					tCenterY = tCenterX + tYOffset;
				}
				
				tXOffset += aRect.left;
				tYOffset += aRect.top;
				tCenterX += aRect.left;
				tCenterY += aRect.top;
				
				tPaint.setStyle(Style.FILL);
				tPaint.setColor(Color.YELLOW);
				
				tPath.addCircle(tCenterX, tCenterY, tRefLen * 0.5f, Direction.CW);
				if (iBackColor == Color.TRANSPARENT){
					tPath.addCircle(tCenterX, tCenterY, tRefLen * 0.37f, Direction.CCW);
				}
				aCanvas.drawPath(tPath, tPaint);
				if (iBackColor != Color.TRANSPARENT){
					tPaint.setColor(iBackColor);
					
					aCanvas.drawCircle(tCenterX, tCenterY, tRefLen * 0.37f, tPaint);
					
					tPaint.setColor(Color.YELLOW);
				}
				
				aCanvas.drawCircle(tCenterX, tRefLen * 0.25f + tYOffset, tRefLen * 0.075f, tPaint);
				aCanvas.drawRect(tRefLen * 0.425f + tXOffset, tRefLen * 0.25f + tYOffset, tRefLen * 0.575f + tXOffset, tRefLen * 0.55f + tYOffset, tPaint);
				aCanvas.drawCircle(tCenterX, tRefLen * 0.55f + tYOffset, tRefLen * 0.075f, tPaint);
				
				aCanvas.drawCircle(tCenterX, tRefLen * 0.75f + tYOffset, tRefLen * 0.075f, tPaint);
			}
		}
		
		return false;
	}

}
